package com.spring.service.impl;

import com.spring.dao.JpaAccountDao;
import com.spring.dao.JpaItemDao;
import com.spring.service.PetStoreService;

public class PetStoreServiceImpl implements PetStoreService {


    private JpaAccountDao accountDao;

    private JpaItemDao itemDao;


    public PetStoreServiceImpl(){
        System.out.println("PetStoreServiceImpl no arg");
    }

    /**
     * 基于构造函数注入
     *      一般用构造函数注入，
     *      对象属性要与构造函数传入参数名称相同
     *      如:accountDao[对象属性 ]->accountDao[方法入参 ]
     * @param accountDao
     * @param itemDao
     */
    public PetStoreServiceImpl(JpaAccountDao accountDao,JpaItemDao itemDao){
        System.out.println("PetStoreServiceImpl has args ");
        this.accountDao = accountDao;
        this.itemDao = itemDao;
    }

    /**
     * 基于setter注入-
     *      一般用setter注入，
     *      对象属性要与set方法去掉"set"后[余下字符中除第一个字母小写，其余不变]的字符一致。
     *      如setAccountDao->accountDao
     * @param accountDao_S
     */
    public void setAccountDao(JpaAccountDao accountDao_S) {
        this.accountDao = accountDao_S;
    }
    /**
     * 基于setter注入
     * @param itemDao_S
     */
    public void setItemDao(JpaItemDao itemDao_S) {
        this.itemDao = itemDao_S;
    }

    @Override
    public void getAccountInf() {
        accountDao.getAccountInf();
    }

    @Override
    public void getItemInf() {
        itemDao.getItemInf();
    }

    @Override
    public String toString() {
        return "PetStoreServiceImpl{" +
                "accountDao=" + accountDao +
                ", itemDao=" + itemDao +
                '}';
    }
}
